﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TDM.WebBase
{
    /// <summary>
    /// 获得基础地址
    /// </summary>
    public class BasePathHelper
    {
        /// <summary>
        /// 系统文件基础地址
        /// </summary>
        public static string BasePath { get; set; }

        /// <summary>
        /// 获得项目文件基础目录
        /// </summary>
        /// <remarks>路径存放规则(试验结果文件): \Project\{PrjID}\{TaskID}\ResultFile\{ResultID}\{FileType}\{FileID.*}</remarks>
        /// <returns></returns>
        public static string GetProjectBasePath()
        {
            var prjectPath = Path.Combine(BasePath, "Project");
            Directory.CreateDirectory(prjectPath);
            return prjectPath;
        }

        /// <summary>
        /// 获得模板文件目录
        /// </summary>
        /// <returns></returns>
        public static string GetTemplatePath()
        {
            var templatePath = Path.Combine(BasePath, "Template");
            Directory.CreateDirectory(templatePath);
            return templatePath;
        }

        /// <summary>
        /// 获得Xls导入导出文件目录
        /// </summary>
        /// <returns></returns>
        public static string GetXlsBasePath()
        {
            var exportPath = Path.Combine(BasePath, "Xls");
            Directory.CreateDirectory(exportPath);
            return exportPath;
        }

        /// <summary>
        /// 获得数据包同步基础文件目录
        /// </summary>
        /// <returns></returns>
        public static string GetDataSyncBasePath()
        {
            var exportPath = Path.Combine(BasePath, "DataSync");
            Directory.CreateDirectory(exportPath);
            return exportPath;
        }

        public static string GetDataExportPath()
        {
            var exportPath = Path.Combine(BasePath, "DataExport");
            Directory.CreateDirectory(exportPath);
            return exportPath;
        }

        public static string GetDataImportPath()
        {
            var exportPath = Path.Combine(BasePath, "DataImport");
            Directory.CreateDirectory(exportPath);
            return exportPath;
        }
    }

    /// <summary>
    /// 后端服务配置项
    /// </summary>
    public static class WebConfigHelper
    {
        /// <summary>
        /// 后端文件基础路径
        /// </summary>
        public static string BaseFileUrl { get; private set; }

        /// <summary>
        /// 设置基础url
        /// </summary>
        /// <param name="url"></param>
        public static void SetBaseFileUrl(string url)
        { BaseFileUrl = url; }
    }
}
